<?php

namespace App\Services\Ext\Sms;

use Flc\Dysms\Request\SendSms;

class AliService
{
    private mixed $client;
    private array $conf = [];

    public function client(array $config)
    {
        $this->conf = $config;
        $this->client = new \Flc\Dysms\Client($config);
        return $this;
    }

    public function send(string $mobile, int $code, string $outId = 'demo')
    {
        return $code;
        $sendSms = new SendSms();
        $sendSms->setPhoneNumbers($mobile);
        $sendSms->setSignName($this->conf['signName']);
        $sendSms->setTemplateCode($this->conf['templateCode']);
        $sendSms->setTemplateParam(['code' => $code]);
        $sendSms->setOutId($outId);
        return 'OK' === $this->client->execute($sendSms)->Code ? $code : false;
    }
}
